using MicroMsg.Common.Event;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Tasks;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace MicroMsg.UI.Page
{
	public class FeedBackPage : BasePage
	{
		private EventWatcher m_SendFeedBackOK;
		private EventWatcher m_SendFeedBackErr;
		private ApplicationBar mBar;
		internal Grid LayoutRoot;
		internal TextBlock txtTitle;
		internal Grid ContentPanel;
		internal PhoneTextBox txtInputFeedBack;
		internal ClickableLayout textPhone;
		internal TextBlock txtTelLabel;
		private bool _contentLoaded;
		public FeedBackPage()
		{
			this.InitializeComponent();
			base.set_ApplicationBar(this.GetApplicationBar());
			base.add_Loaded(new RoutedEventHandler(this.initData));
		}
		private void initData(object sender, RoutedEventArgs e)
		{
			this.txtInputFeedBack.Focus();
		}
		public IApplicationBar GetApplicationBar()
		{
			if (this.mBar != null)
			{
				return this.mBar;
			}
			this.mBar = new ApplicationBar();
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			ApplicationBarIconButton applicationBarIconButton = new ApplicationBarIconButton(new Uri("/Resource/Img/CommonUse/ico_save.png", 2));
			applicationBarIconButton.set_Text(strings.COM_Send);
			applicationBarIconButton.add_Click(new EventHandler(this.sendButton_Click));
			this.mBar.get_Buttons().Add(applicationBarIconButton);
			return this.mBar;
		}
		private void sendButton_Click(object sender, EventArgs e)
		{
			string text = this.txtInputFeedBack.get_Text().Trim();
			if (text.get_Length() == 0)
			{
				MessageBoxManager.ShowToast(strings.Set_Feedback_EmptyMsg, 2500, null, false);
				this.txtInputFeedBack.Focus();
				return;
			}
			this.showProgressCover(strings.Set_Feedback_Sending);
			ServiceCenter.sceneSendFeedback.doScene(text);
		}
		private void cancelButton_Click(object sender, EventArgs e)
		{
			base.GoBack();
		}
		private void txtGotFofus(object sender, RoutedEventArgs e)
		{
			PhoneTextBox phoneTextBox = sender as PhoneTextBox;
			phoneTextBox.set_BorderBrush(R.theme.COMMON_BRUSH);
		}
		protected override void OnPageIn(object[] object_0)
		{
			this.m_SendFeedBackOK = new EventWatcher(this, null, new EventHandlerDelegate(this.onEventSendFeedBackOK));
			this.m_SendFeedBackErr = new EventWatcher(this, null, new EventHandlerDelegate(this.onEventSendFeedBackErr));
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_FEED_BACK_SUCCESS, this.m_SendFeedBackOK);
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_FEED_BACK_ERR, this.m_SendFeedBackErr);
			if (R.isEnglish())
			{
				this.textPhone.set_Visibility(1);
			}
		}
		protected override void OnPageOut()
		{
			if (this.m_SendFeedBackOK == null)
			{
				return;
			}
			EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_FEED_BACK_SUCCESS, this.m_SendFeedBackOK);
			this.m_SendFeedBackOK = null;
			EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_FEED_BACK_ERR, this.m_SendFeedBackErr);
			this.m_SendFeedBackErr = null;
		}
		private void onEventSendFeedBackOK(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.hideProgressCover();
			MessageBoxManager.ShowToast(strings.Set_Feedback_Send_OK, 2500, null, false);
			base.Focus();
			this.txtInputFeedBack.set_Text("");
		}
		private void onEventSendFeedBackErr(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.hideProgressCover();
			MessageBoxManager.ShowToast(strings.Set_Feedback_Send_Err, 2500, null, false);
		}
		private void showProgressCover(string strCoverTitle)
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, strCoverTitle, (SolidColorBrush)Application.get_Current().get_Resources().get_Item("HalfOpacityBrush1"), false, false, null);
		}
		private void hideProgressCover()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
		}
		private void inputTxt_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.get_Key() == 3)
			{
				this.txtInputFeedBack.set_Text(this.txtInputFeedBack.get_Text() + "\n");
				this.txtInputFeedBack.set_SelectionStart(this.txtInputFeedBack.get_Text().get_Length());
			}
		}
		private void textPhoneClick(object sender, RoutedEventArgs e)
		{
			PhoneCallTask phoneCallTask = new PhoneCallTask();
			phoneCallTask.set_PhoneNumber("86075561369988");
			phoneCallTask.set_DisplayName(strings.Set_AboutMM_ServiceTel);
			phoneCallTask.Show();
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Setting/FeedBackPage.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.txtTitle = (TextBlock)base.FindName("txtTitle");
			this.ContentPanel = (Grid)base.FindName("ContentPanel");
			this.txtInputFeedBack = (PhoneTextBox)base.FindName("txtInputFeedBack");
			this.textPhone = (ClickableLayout)base.FindName("textPhone");
			this.txtTelLabel = (TextBlock)base.FindName("txtTelLabel");
		}
	}
}
